package com.mdc.action;

//import com.mdc.service.UserService;
import com.mdc.service.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

//import javax.annotation.Resource;

/**
 *
 * @author Mordecai
 * @version 1.0.0
 * @blog https://gitee.com/mordeky/SpringBoot
 *
 */
@Controller
@Scope("prototype")
public class UserAction {
    // 注入userService
    //@Resource(name = "userService")
    @Autowired
    //private UserService userService;
    private UserServiceImpl userService;

    // http://localhost:8080/add
    @ResponseBody
    @RequestMapping("/add")
    public Integer add(){
        userService.create("Tom", 100);
        return userService.getAllUsers();
    }

    // http://localhost:8080/controller/hello2
    @ResponseBody
    @RequestMapping("/hello2")
    public String getStr2(){ return "index"; }
}